package org.security.oauth2.domain;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.security.oauth2.model.Role;

@Mapper
public interface RoleMapper {
	/**
     * 取得用户角色
     * @param username 用户名
     * @return 角色列表
     */
    @Select("<script>" +
            "SELECT " + 
            "role.name as roleName " + 
            "FROM " + 
            "role,user_role " + 
            "WHERE " + 
            "  role.id = user_role.role_id " + 
            "AND user_role.user_name = #{username}" +
            "</script>")
    public List<Role> roleList(@Param("username") String username);

}
